﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void startBatton_Click(object sender, EventArgs e)
        {
            try
            {   
                //用户无输入
                if(numTextBox.Text.Equals(String.Empty)|| timeTextBox.Text.Equals(String.Empty))
                {
                    throw new Exception("时间或题目量不能为空");
                }
                int time = Convert.ToInt32(numTextBox.Text);
                int num= Convert.ToInt32(timeTextBox.Text);
                //用户输入超范围
                if (time < 0 || time > 99)
                {
                    throw new Exception("时间超出限定范围");
                }
                if (num < 0 || num > 99)
                {
                    throw new Exception("题目量超出限定范围");
                }
                CountForm cf = new CountForm(num, time);
                this.Hide();
                cf.ShowDialog();
                this.Show();
            }
            catch(Exception ex)
            {   
                
                MessageBox.Show(ex.Message);
            }

            
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
